<?php

class UserInformation_model extends CI_Model
{
	function getUserInformation($id)
	{	
		
		
		$sqlCommand='SELECT * FROM kund WHERE ID = ?';
		$query=$this->db->query($sqlCommand,array($id));
		
		
		if ($query->num_rows() >= 1)
		{	
			
			$userInfo = $query->row();
			return $userInfo;
		}
		
		else
		{
			echo "Fel! hittade inte annvändaren, var vänlig kolla så du är inloggad";
		}
	}
	

	function saveNewFname($id, $newFname)
	{
		
		
		
			$sqlCommand='UPDATE kund SET Fnamn= ? WHERE ID = ?';
			$query=$this->db->query($sqlCommand,array($newFname, $id));
		
			return $query;
		
	}
	
	
		function saveNewLname($id, $newLname)
	{
		
		
		
			$sqlCommand='UPDATE kund SET Enamn= ? WHERE ID = ?';
			$query=$this->db->query($sqlCommand,array($newLname, $id));
		
			return $query;
		
	}
	
		function saveNewPnumber($id, $newPnumber)
	{
		
		
		
			$sqlCommand='UPDATE kund SET Personnummer= ? WHERE ID = ?';
			$query=$this->db->query($sqlCommand,array($newPnumber, $id));
		
			return $query;
		
	}
	
		function saveNewAdress($id, $newAdress)
	{
		
		
		
			$sqlCommand='UPDATE kund SET Adress= ? WHERE ID = ?';
			$query=$this->db->query($sqlCommand,array($newAdress, $id));
		
			return $query;
		
	}
	
		function saveNewTelNumber($id, $newTelNumber)
	{
		
		
		
			$sqlCommand='UPDATE kund SET TelNummer= ? WHERE ID = ?';
			$query=$this->db->query($sqlCommand,array($newTelNumber, $id));
		
			return $query;
		
	}
	
		function saveNewEmail($id, $newEmail)
	{
		
		
		
			$sqlCommand='UPDATE kund SET Email= ? WHERE ID = ?';
			$query=$this->db->query($sqlCommand,array($newEmail, $id));
		
			return $query;
		
	}
	
	function saveNewPassword($id, $newPassword)
	{
		$hashPassword=do_hash($newPassword);
		
		$sqlCommand='UPDATE kund SET password= ? WHERE ID = ?';
		$query=$this->db->query($sqlCommand,array($hashPassword, $id));
		
		return $query;
		
	}
}
	